<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core_rt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="f"%>
<%@ taglib uri="/mytag" prefix="yjd"%>
<div class="wrap" >
    <button type="button" class="btn  length_2"
            onclick="window.location.href='${requestScope.FPWEB.rootPath }/authority/user/list${requestScope.FPWEB.urlStuff}'">添加授权</button>
    <div class="table_list">
        <table width="100%">
            <thead>
                <tr>
                    <td>ID</td>
                    <td>登录名</td>
                    <td>权限</td>
                    <td>添加时间</td>
                    <td>最后更新时间</td>
                    <td>操作</td>
                </tr>
            </thead>
            <tbody id="J_word_list">
            <c:forEach items="${pager.pagerModel.dataList }" var="item" varStatus="i">
                <tr>
                    <td>${item.admin_id}</td>
                    <td>${item.strMap.username}</td>
                    <td>
                        <c:forEach var="itm" items="${item.strMap.authorityList}">
                            <input type="checkbox" value="${itm.value}" name="${item.admin_id}" <c:if test="${itm.checked == true}">checked</c:if>>${itm.dcpt} <br/>
                        </c:forEach>
                    </td>
                    <td>${item.strMap.create_time}</td>
                    <td>${item.strMap.update_time}</td>
                    <td>
                        <a class="btn btn_submit" href="#" onclick="return submitAthity(${item.admin_id})">保存</a>
                        <a class="btn btn_submit" href="${requestScope.FPWEB.rootPath }/authority/delete${requestScope.FPWEB.urlStuff}?id=${item.admin_id}">删除</a>
                    </td>
                </tr>
            </c:forEach>
            </tbody>
        </table>
    </div>
    <!-- 分页 -->
    <%@ include file="../public/pager/pager.pagination.jsp" %>
</div>

<script>
    YJD.use('AppAdminCommon');
    YJD.use('AppBICommon');
    function submitAthity(cbx) {
        var chk = 0;
        var chkbx = $('input[name=' +cbx+ '][checked]');
        chkbx.each(function(){
            chk = chk | $(this).val();
        });
        $.ajax({
            async:false,
            url:'${requestScope.FPWEB.rootPath }/authority/save${requestScope.FPWEB.urlStuff}?id='+cbx+'&athity='+chk,
            success:function(data){
                alert(data.message);
            },
            error:function(req, msg){
                alert(msg);
            }
        });
    };
</script>
